<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ include file="/common-app/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>申请书编辑</title>
    <script type="text/javascript" src="${res}/js/jquery/jquery.form.js"></script>
    <script type="text/javascript"
            src="${res}/js/proposal/irisPrpPrepare.js"></script>
    <script type="text/javascript"
            src="${res}/js/validate/irisvalidator.js"></script>
    <script type="text/javascript"
            src="${res}/js/keyword/keywordtips.js"></script>
    <script type="text/javascript"
            src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
    <script type="text/javascript"
            src="${res_app}/js/app/base.js"></script>
    <script type="text/javascript">

        var ctxpath = "${ctx}";
        var prcWin = new progressWin("${res}");//初始化遮罩层
        $(document).ready(function () {
            queryflex();
            /**
             * 申请书提交方法
             */
            $("#wbox1").click(function () {
                check("check");
            });
            $("#wbox2").click(function () {
                check("check");
            });
            initControl();
            $("table.t_css").each(function () {
                $(this).find("tr:even").removeClass().addClass("li_1");
                $(this).find("tr:odd").removeClass().addClass("li_2");
            });
            $("table").addClass("table01");
            $("#checkbox_table_").removeClass("table01");
            $("#feaReport_upload1").removeClass("table01");
            $("#feaReport_upload2").removeClass("table01");
            $("div[id^='checkbox_dyn_']").each(function () {
                $(this).find("tr").removeClass("li_1")
                $(this).find("tr").removeClass("li_2")
            })
           /* $('div').find("[id^='checkbox_dyn_']").find("tr").removeClass("li_1").removeClass("li_2");
            $('div').find("[id^='checkbox_dyn_']").find("td").css("border", '0px solid');*/
            window.setInterval("checkPdfStatus()", "10000");//检验申请书的pdf
            fileInit("feaReport_upload", "DOC,DOCX,PDF,WPS");
            fileInit("prpContent_upload", "PDF,DOC,DOCX,WPS", null, "{'PDF':'51200','DOCX':'51200','DOC':'51200','WPS':'51200'}");
            $("#prpContent_upload").find(".file").hide();//隐藏文本框
            fileInit("feaReport_upload1", "PDF", null, "{'PDF':'51200'}");
            fileInit("feaReport_upload2", "PDF", null, "{'PDF':'51200'}");
            $("#org").attr("disabled", "true");
            initDepartForComplete("org");

        });

        /**
         * 申报日期默认为当前日期
         */
        $(document).ready(function () {
            var nowDate = '${sercverSysDate1}';
            if ($("#apply_date_curr").val() == "") {
                $("#apply_date_curr").val(nowDate);
            }

            /*compare_age();*/
/*
            grant_code();
*/
        });

        /**
         * 填写检查
         */
        function check(type) {
            setTotalAmt();
            validate($("#basic_tab"), "项目基本情况");
            /*compare_age1();*/
            validateByTabRow($("#inland"), "项目基本情况-->合作单位信息", 0);
            validate($("#tblMileStones0"), "项目基本情况");
            validate($("#feaReport_upload1"), "项目概述");
            validate($("#main_research_tb"), "主要内容");
            validate($("#feaReport_upload2"), "主要目标");
            validate($("#goal_info"), "项目绩效目标");
            validate($("#tblresume"), "项目人员情况");
            validate($("#fundInfo_from"), "");
           /* var nature_value = $("#nature_value").val();

            if (nature_value.indexOf("A") != -1) {
                check_unit_funds(total_each_2, total_investfrom_5);
            }*/
            validate($("#fundInfo"), "");
           /* check_gold(total_each_0, total_fund_17, total_fund_0, total_fund_2);*/
            validate($("#tbl"), "经费预算");
            validateByTabRow($("#shibei"),"经费预算-->项目拟购置、试制科研仪器设备清单",0);

            /*经费计算年度合法检查  */
            for (index = 1; index <= 3; index++) {
                var yearobj = $("#income_year_before" + index);
                irisValYearByObj(yearobj);
            }
            validateByTabRow($("#tblMileStones"), "项目进度计划", 1);
            validate($("#performances"), "绩效目标");

            /*checkper();*/
            prp_attach();
            if (!valResult()) {
                irisValShowMsg($("#wbox1"));
                return false;
            }
            if (type == "check") {
                showBox($("#wbox1"), "300px", "200px", "检查通过", "1:所有检查全部合格");
            }
            return true;
        }
        function setTotalAmt() {
            $('#total_amt').val($("#input_total").val());
            $('#request_amt').val($("#request_amount").val());
        }

        function synchronizationAmount() {
            var request_amount = $("#request_amount").val();
            if (request_amount != "") {
                $("#total_each_0").val(parseFloat($("#request_amount").val()).toFixed(2));
                countFundAuto('total_', 'each_0,each_1,each_2,each_4', 'investfrom_5');
            } else if (request_amount == "") {
                $("#total_each_0").val("");
                countFundAuto('total_', 'each_0,each_1,each_2,each_4', 'investfrom_5');
            }
        }
        function setUnitTerritory() {
            var effectivenes_units = $("#effectivenes_units").val();
            if (effectivenes_units.indexOf('1') < 0 && effectivenes_units.indexOf('2') < 0 && effectivenes_units.indexOf('3') < 0) {
                irisValaddMsg("项目基本情况-->合作单位信息-->合作单位属地最少要有一个在江浙沪");
            }
        }
        function check_unit_funds(total_each_id, total_investfrom_id) {
            var total_each_id = parseFloat($("#" + total_each_id.id + "").val());
            var total_investfrom_id = parseFloat($("#" + total_investfrom_id.id + "").val());
            if (total_each_id < total_investfrom_id * 0.6) {
                irisValaddMsg("经费预算-->经费预算-->资金预算-->资金来源-->单位自筹经费大于等于经费预算-->经费预算-->资金预算-->资金来源-->来源合计-->预算金额的60%");
            }
        }
        //经费验证吧
        function check_gold(provinceMoneyId, indirectMoneyId, directMoneyId, equipmentMoneyId) {
            var get_money = parseFloat($("#" + provinceMoneyId.id + "").val());

            var indirect_money = parseFloat($("#" + indirectMoneyId.id + "").val());

            var direct_money = parseFloat($("#" + directMoneyId.id + "").val());

            var equipment_money = parseFloat($("#" + equipmentMoneyId.id + "").val());

            var left_money = parseFloat(direct_money - equipment_money);

            if (get_money < 100) {
                if (indirect_money > left_money * 0.3) {
                    irisValaddMsg("经费预算-->资金预算-->资金来源预算-->省财政拨款-->预算金额小于100万元时，资金支出预算-->其中：省财政拨款间接费用不能超过直接费用减去购置设备费后的30%");
                }
            }
            if (get_money < 300 && get_money >= 100) {
                if (indirect_money > left_money * 0.25) {
                    irisValaddMsg("经费信息-->资金预算-->资金来源预算-->省财政拨款-->预算金额小于300万元并且大于100万元(包含100万元)时，其中：省财政拨款间接费用不能超过直接费用减去购置设备费后的25%");
                }
            }
            if (get_money < 500 && get_money >= 300) {
                if (indirect_money > left_money * 0.2) {
                    irisValaddMsg("经费预算-->资金预算-->资金来源预算-->省财政拨款-->预算金额小于500万元并且大于300万元(包含300万元)时，其中：省财政拨款间接费用不能超过直接费用减去购置设备费后的20%");
                }
            }
            if (get_money >= 500) {
                if (indirect_money > left_money * 0.15) {
                    irisValaddMsg("经费预算-->资金预算-->资金来源预算-->省财政拨款-->预算金额大于500万元(包含500万元)时，其中：省财政拨款间接费用不能超过直接费用减去购置设备费后的15%");
                }
            }
        }

        function compare_age1() {
            var end_date = $("#end_date").val();
            var end_date_year = Number(end_date.substring(0, 4));
            if (end_date_year >= 2023) {
                irisValaddMsg("项目基本情况-->项目结束日期必须小于等于2022年12月31日");
            }
        }
    </script>

    <style>
        textarea {
            overflow: auto;
        }
    </style>
</head>
<body>
<c:set var="xmlstr" value="${xmlData}" scope="request"/>
<x:parse xml="${xmlstr}" var="xmlData" scope="request"/>
<input type="hidden" id="childDiv" class="thickbox"/>
<input type="hidden" id="filePath" value="${ctx}/file/ajax-filedownload?fileCode="/>
<input type="hidden" id="menuId" value="${param.menuId}"/>
<input type="hidden" id="sysDate" value="${sercverSysDate}"/>
<input type="hidden" id="registration_type" value="<x:out select="$xmlData/data/organization/registration_type" />"/>
<input type="hidden" id="flat_type" value="<x:out select="$xmlData/data/organization/flat_type" />"/>
<div id="showMessage"></div>
<div id="content">

    <cpt:helpTips key="prpedit" id="prpEditTips"></cpt:helpTips>
    <div class="clear_h15"></div>
    <div class="word_box" id="mainDiv">

        <!-- 公用的配置界面 ：保存、提交等button-->
        <jsp:include page="./prpeditmain_public_first_z_2019.jsp"/>

        <div class="bar_b">
            <input type="hidden" id="pdfStatus" value="${pdfStatus}"/>
            <span class="right">版本号：<span name="proposal/prp_version" id="prp_version"><x:out
                    select="$xmlData/data/proposal/prp_version"/></span></span>
        </div>
        <form method="post" id="mainForm">
            <input type="hidden" value="${grantCode}" id="grantCode" name="grantCode">
            <input type="hidden" value="${posCode}" id="posCode" name="posCode">
            <input type="hidden" value="<iris:des3 code="${posCode}"></iris:des3>" id="posCodeDes" name="posCodeDes">
            <input type="hidden" value="<iris:des3 code="${fbl.pdfCode}"></iris:des3>" id="pdfCodeDes"
                   name="pdfCodeDes">
            <input type="hidden" value="${xmlData}" id="xmlData" name="xmlData">
            <input type="hidden" value="${fbl.pdfCode}" id="pdfCode" name="pdfCode">
            <input type="hidden" value="${flag_shizhi}" id="flag_shizhi" name="proposal/flag_shizhi">
        </form>
        <div class="word_title">
            <c:set var="statYear" scope="request">${statYear}</c:set>
            <c:if test="${empty statYear}">
                <c:set var="statYear" scope="request"><x:out select="$xmlData/data/proposal/stat_year"/></c:set>
            </c:if>
            <input type="hidden" name="proposal/stat_year" value="${statYear}">
           <%-- <c:set var="pro_end_date">${pro_end_date}</c:set>
            <c:if test="${empty pro_end_date}">
                <c:set var="pro_end_date"><x:out select="$xmlData/data/proposal/end_date"/></c:set>
            </c:if>--%>
            <%-- <input type="hidden" id="end_date" name="proposal/end_date" value="<x:out select="$xmlData/data/proposal/end_date" />" label="项目截止时间"/>--%>
           <%-- <input type="hidden" id="start_date" name="proposal/start_date"
                   value="<x:out select="$xmlData/data/proposal/start_date" />" label="项目开始时间"/>--%>
            <%--<input type="hidden" id="end_date" name="proposal/end_date" value="${pro_end_date}" label="项目截止时间"/>
            <input type="hidden" id="start_date" name="proposal/start_date" value="${pro_start_date}" label="项目开始时间"/>--%>
            <%--<input type="hidden" name="proposal/pro_start_date" value="${pro_start_date}">
            <input type="hidden" name="proposal/pro_end_date" value="${pro_end_date}">--%>
            <c:set var="sub"><x:out select="$xmlData/data/proposal/sub_grant_code"/></c:set>

            <!-- 标题 -->
            <c:set var="show_sub_grant_name"><x:out select="$xmlData/data/proposal/show_sub_grant_name"/></c:set>
            <input type="hidden" name="proposal/grant_name" value="<x:out select="$xmlData/data/proposal/grant_name" />" />
            <span name="proposal/sub_grant_name"><x:out select="$xmlData/data/proposal/sub_grant_name"/></span>-项目申报书
            (${statYear }年)
            <input type="hidden" id="age" name="proposal/attach_age"
                   value="<x:out select="$xmlData/data/proposal/attach_age" />"/>
            <%--   <input type="hidden" id="end_date" name="proposal/end_date" value="<x:out select="$xmlData/data/proposal/end_date" />"/>--%>
            <input type="hidden" id="fzbirthday"
                   value="<x:out select="$xmlData/data/zh_persons/zh_person/basic_info/birthday" />"/>
            <input type="hidden" id="control_psn_code" name="proposal/control/psn_code"
                   value="<x:out select="$xmlData/data/proposal/control/psn_code" />"/>

            <input type="hidden" id="fzr_birthday"
                   value="<x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/birthday" />">
            <input type="hidden" id="degree_name"
                   value="<x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/degree_name" />"/>
            <input type="hidden" id="level_no" name="proposal/level_no"
                   value="<x:out select="$xmlData/data/proposal/level_no" />">
            <input type="hidden" name="proposal/manage_category"
                   value="<x:out select="$xmlData/data/proposal/manage_category" />"/>
            <input type="hidden" name="proposal/grant_code"
                   value="<x:out select="$xmlData/data/proposal/grant_code" />"/>
            <input type="hidden" id="psn_code" name="proposal/psn_code"
                   value="<x:out select="$xmlData/data/proposal/psn_code" />"/>
            <input type="hidden" id="grant_no" name="proposal/grant_no"
                   value="<x:out select="$xmlData/data/proposal/grant_no" />"/>
            <input type="hidden" name="proposal/sub_grant_code" id="grant_code"
                   value="<x:out select="$xmlData/data/proposal/sub_grant_code" />"/>
            <input name="proposal/register_area_code" type="hidden"
                   value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/area_value" />"/>
            <input name="proposal/register_area_name" type="hidden"
                   value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/area_name" />"/>
            <input type="hidden" id="sub_grant_no" name="proposal/sub_grant_no"
                   value="<x:out select="$xmlData/data/proposal/sub_grant_no" />"/>
            <input type="hidden" name="proposal/help_grant_code"
                   value="<x:out select="$xmlData/data/proposal/help_grant_code" />"/>
            <input type="hidden" id="help_grant_no" name="proposal/help_grant_no"
                   value="<x:out select="$xmlData/data/proposal/help_grant_no" />"/>
            <c:set var="formCode"><x:out select="$xmlData/data/proposal/form_code"/></c:set>
            <c:set var="nature_value"><x:out
                    select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value"/> </c:set>
            <c:if test="${empty formCode}"><c:set var="formCode" value="${param.formCode}"></c:set></c:if>
            <input type="hidden" name="proposal/form_code" value="${formCode}"/>
            <input type="hidden" name="proposal/request_amt" id="request_amt"
                   value="<x:out select="$xmlData/data/proposal/request_amt"/>">
            <input type="hidden" name="proposal/year" value="${year}"/>
            <input type="hidden" name="organizations/organization/nature_value"
                   value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />"/>
            <input type="hidden" name="organization/whether_is_gaoxin_value"
                   value="<x:out select="$xmlData/data/organization/whether_is_gaoxin_value" />"/>
            <input type="hidden" name="organization/whether_industrial_base_value"
                   value="<x:out select="$xmlData/data/organization/whether_industrial_base_value" />"/>
            <input type="hidden" name="organization/whether_is_province_value"
                   value="<x:out select="$xmlData/data/organization/whether_is_province_value" />"/>
            <input type="hidden" name="organization/whether_is_provincepark_value"
                   value="<x:out select="$xmlData/data/organization/whether_is_provincepark_value" />"/>
            <input type="hidden" name="organizations/organization/nature_value" id="nature_value"
                   value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />">
            <input type="hidden" id="age_end_date" name="proposal/age_end_date"
                   value="<x:out select="$xmlData/data/proposal/age_end_date"/>"/>
            <input type="hidden" id="grantcode1" name="proposal/grantcode1"
                   value="<x:out select="$xmlData/data/proposal/grantcode1" />"/>
            <!-- 申请日期 -->
            <%-- <input type="hidden" id="submit_date" name="proposal/submit_date" value="<x:out select="$xmlData/data/proposal/submit_date" />" /> --%>
            <!-- 公用的配置界面 -->
            <jsp:include page="./prpeditmain_public.jsp"/>
        </div>

        <div id="tabnav">
            <ul>
                <li class="down" id="tab1" onclick="changeTab(this.id)">
                    <a href="###"><span>单位基本情况</span></a>
                </li>

                <li id="tab2" onclick="changeTab(this.id)">
                    <a href="###"><span>项目基本情况</span></a>
                </li>
                <li id="tab3" onclick="changeTab(this.id)">
                    <a href="###"><span>项目概述</span></a>
                </li>
                <li id="tab4" onclick="changeTab(this.id)">
                    <a href="###"><span>主要内容</span></a>
                </li>

                <li id="tab5" onclick="changeTab(this.id)">
                    <a href="###"><span>主要目标</span></a>
                </li>
                <li id="tab6" onclick="changeTab(this.id)">
                    <a href="###"><span>项目绩效目标</span></a>
                </li>
                <li id="tab7" onclick="changeTab(this.id)">
                    <a href="###"><span>项目人员情况</span></a>
                </li>
                <li id="tab8" onclick="changeTab(this.id)">
                    <a href="###"><span>经费预算</span></a>
                </li>
                <li id="tab9" onclick="changeTab(this.id)">
                    <a href="###"><span>项目进度计划</span></a>
                </li>

            </ul>
        </div>
        <div id="tabnav">
            <ul>
                <li id="tab10" onclick="changeTab(this.id)">
                    <a href="###"><span>绩效目标</span></a>
                </li>
                <li id="tab11" onclick="changeTab(this.id)">
                    <a href="###"><span>附件清单</span></a>
                </li>
            </ul>
        </div>
        <!-- 单位基本情况-->
        <div class="tab_box" id="fragment-tab1">
            <jsp:include page="../org/prporg_baseinfo_enterprise_new_2020.jsp">
                <jsp:param value="1、单位基本信息" name="title"/>
                <jsp:param value="2、单位人员情况" name="title2"/>
                <jsp:param value="3、单位财务状况" name="title3"/>
                <jsp:param value="4、企业开展产学研合作情况" name="title4"/>
                <jsp:param value="5、主营业务产品" name="title5"/>
                <jsp:param value="6、知识产权情况" name="title6"/>
                <jsp:param value="${xmlstr}" name="xmlstr"/>
                <jsp:param value="${statYear}" name="statyear"/>
                <jsp:param value="${year}" name="curryear"/>
            </jsp:include>
        </div>
        <!-- 项目基本情况-->
        <div class="tab_box" id="fragment-tab2" style="display: none">
            <jsp:include page="../info/prpinfoEdit_ycyzsf_2020.jsp">
                <jsp:param value="${statYear}" name="statYear"/>
                <jsp:param value="${pro_start_date}" name="pro_start_date"/>
                <jsp:param value="${pro_end_date}" name="pro_end_date"/>
                <jsp:param value="${xmlstr}" name="xmlstr"/>
            </jsp:include>
        </div>
        <!-- 项目概述 -->
        <div class="tab_box" id="fragment-tab3" style="display: none">
            <jsp:include page="../content/prpContentEdit_gjkxzx_2020.jsp">
                <jsp:param value="${xmlstr}" name="xmlstr"/>
                <jsp:param value="项目概述" name="title"/>
            </jsp:include>
        </div>

        <!--主要内容 -->
        <div class="tab_box" id="fragment-tab4" style="display: none">
            <jsp:include page="../org/prporgedit_gjkxzx_2020.jsp"></jsp:include>
        </div>
        <!--主要目标-->
        <div class="tab_box" id="fragment-tab5" style="display: none">
            <jsp:include page="../content/prpContentEdit_gjkxzx_2020_1.jsp">
                <jsp:param value="${xmlstr}" name="xmlstr"/>
                <jsp:param value="主要目标" name="title"/>
            </jsp:include>
        </div>
        <div class="tab_box" id="fragment-tab6" style="display: none">
            <jsp:include page="../goal/prpgoaledit_ycyzsf_2020.jsp">
                <jsp:param value="${xmlstr}" name="xmlstr"/>
            </jsp:include>
        </div>
        <!--人员信息-->
        <div class="tab_box" id="fragment-tab7" style="display: none">
            <jsp:include page="../psn/prpzhpsn_ycyzsf_2020.jsp">
                <jsp:param value="${xmlstr}" name="xmlstr"/>
            </jsp:include>
        </div>
        <!--经费预算-->
        <div class="tab_box" id="fragment-tab8" style="display: none">
            <jsp:include page="../fund/prpfundedit_public_gjkxzx_2020.jsp">
                <jsp:param value="${xmlstr}" name="xmlstr"/>
                <jsp:param value="${statYear}" name="statYear"/>
            </jsp:include>
        </div>
        <!-- 项目进度计划-->
        <div class="tab_box" id="fragment-tab9" style="display: none">
            <jsp:include page="../milestone/prpmilestoneedit_public_2020.jsp">
                <jsp:param value="${xmlstr}" name="xmlstr"/>
                <jsp:param value="项目进度计划（每个阶段的实施方案、实施地点、阶段性成果等内容，要求详细具体。）（最多添加5行）" name="title"/>
            </jsp:include>
        </div>
        <!--项目绩效-->
        <div class="tab_box" id="fragment-tab10" style="display: none">
            <jsp:include page="../performance/prpperformanceedit_publicgjkxzx_2020.jsp">
                <jsp:param value="${xmlstr}" name="xmlstr"/>
                <jsp:param value="${statYear}" name="statYear"/>
            </jsp:include>
        </div>
        <!-- 需提交的材料-->
        <div class="tab_box" id="fragment-tab11" style="display: none">
            <jsp:include page="../attach/prpAttachEdit_msgg_2019.jsp">
                <jsp:param value="${xmlstr}" name="xmlstr"/>
            </jsp:include>
            <p style="font-size: 13px"><strong>备注：</strong></p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1、递交纸质材料时，提供系统打印的申请书纸质文件，一式四份，签字盖章后报送归口管理单位</p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2、递交纸质材料时，申报单位所在地归口管理单位校验以上附件材料</p>
        </div>

        <!-- 公用的配置界面 ：保存、提交等button -->
        <jsp:include page="./prpeditmain_public_last_z_2019.jsp"/>
    </div>
    <div class="clear_h15"></div>
</div>
</body>
</html>

